<?php

namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller
{
    public function index(){
     $index = M('article');
     $list = $index->limit(0,10)->select();
     $this->assign('list',$list);

     $news = $index->field('a.id,a.title,a.publishtime,b.name')->alias('a')->join('xyh_category b on a.cid=b.id ','left')->limit(0,8)->select();
     $this->assign('news',$news);

     $indexs = M('announce');
        $lists = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('lists',$lists);
        $this->display();
    }
    public function show(){
        $indexs = M('announce');
        $listss = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('listss',$listss);
        $id  = I('id');
        $index = M('article');
<<<<<<< Updated upstream
        $list = $index->find($id);

        $listn = $index->where('id <'.$id)->order('id desc')->limit(1)->find();
        $listl = $index->where('id >'.$id)->order('id asc')->limit(1)->find();

        $preId = $listn['id'];
        if ($index->min('id')>=$listn['id']){
            $preId="";
        }

        $nextId = $listl['id'];
        if ($index->max('id')<=$listl['id']){
            $nextId="";
        }

=======
        $index->where('id='.I('id'))->setInc('click');
        $list = $index->field('title,content,click,publishtime')->find($id);
>>>>>>> Stashed changes
        $lists = $index->select();
        $this->assign('list',$list);
        $this->assign('lists',$lists);
        $this->assign('listn',$listn);
        $this->assign('listl',$listl);

        $this->assign('preId',$preId);
        $this->assign('nextId',$nextId);
        $this->display();
    }

}